home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 November: Tool Chest / Dev.CD Nov 98 TC.toast / Tool Chest / Development Kits / MPW etc. / MPW-GM / Interfaces&Libraries / Interfaces / CIncludes / PCCardTuples.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-02-17  |  13.7 KB  |  469 lines  |  [TEXT/MPS ]

  1. /*
  2.      File:        PCCardTuples.h
  3.  
  4.      Contains:    List of PCMCIA tuple types and definitions of tuple contents.
  5.  
  6.      Version:    Technology:    System 7.5
  7.                  Release:    Universal Interfaces 3.1
  8.  
  9.      Copyright:    © 1994-1998 by Apple Computer, Inc.  All rights reserved.
  10.  
  11.      Bugs?:        Please include the the file and version information (from above) with
  12.                  the problem description.  Developers belonging to one of the Apple
  13.                  developer programs can submit bug reports to:
  14.  
  15.                      devsupport@apple.com
  16.  
  17. */
  18. #ifndef __PCCARDTUPLES__
  19. #define __PCCARDTUPLES__
  20.  
  21. #ifndef __MACTYPES__
  22. #include <MacTypes.h>
  23. #endif
  24.  
  25.  
  26.  
  27. #if PRAGMA_ONCE
  28. #pragma once
  29. #endif
  30.  
  31. #ifdef __cplusplus
  32. extern "C" {
  33. #endif
  34.  
  35. #if PRAGMA_IMPORT
  36. #pragma import on
  37. #endif
  38.  
  39. #if PRAGMA_STRUCT_ALIGN
  40.     #pragma options align=mac68k
  41. #elif PRAGMA_STRUCT_PACKPUSH
  42.     #pragma pack(push, 2)
  43. #elif PRAGMA_STRUCT_PACK
  44.     #pragma pack(2)
  45. #endif
  46.  
  47.  
  48. enum {
  49.     MAX_TUPLE_SIZE                = 256
  50. };
  51.  
  52. /*————————————————————————————————————————————————————————————————————————
  53.     Defines for Tuple codes
  54. ————————————————————————————————————————————————————————————————————————*/
  55.  
  56. enum {
  57.     CISTPL_NULL                    = 0x00,
  58.     CISTPL_DEVICE                = 0x01,
  59.     CISTPL_LONGLINK_CB            = 0x02,
  60.     CISTPL_INDIRECT                = 0x03,
  61.     CISTPL_CONFIG_CB            = 0x04,
  62.     CISTPL_CFTABLE_ENTRY_CB        = 0x05,
  63.     CISTPL_LONGLINK_MFC            = 0x06,
  64.     CISTPL_BAR                    = 0x07,
  65.     CISTPL_CHECKSUM                = 0x10,
  66.     CISTPL_LONGLINK_A            = 0x11,
  67.     CISTPL_LONGLINK_C            = 0x12,
  68.     CISTPL_LINKTARGET            = 0x13,
  69.     CISTPL_NO_LINK                = 0x14,
  70.     CISTPL_VERS_1                = 0x15,
  71.     CISTPL_ALTSTR                = 0x16,
  72.     CISTPL_DEVICE_A                = 0x17,
  73.     CISTPL_JEDEC_C                = 0x18,
  74.     CISTPL_JEDEC_A                = 0x19,
  75.     CISTPL_CONFIG                = 0x1A,
  76.     CISTPL_CFTABLE_ENTRY        = 0x1B,
  77.     CISTPL_DEVICE_OC            = 0x1C,
  78.     CISTPL_DEVICE_OA            = 0x1D,
  79.     CISTPL_DEVICE_GEO            = 0x1E,
  80.     CISTPL_DEVICE_GEO_A            = 0x1F,
  81.     CISTPL_MANFID                = 0x20,
  82.     CISTPL_FUNCID                = 0x21,
  83.     CISTPL_FUNCE                = 0x22,
  84.     CISTPL_SWIL                    = 0x23,
  85.     CISTPL_VERS_2                = 0x40,
  86.     CISTPL_FORMAT                = 0x41,
  87.     CISTPL_GEOMETRY                = 0x42,
  88.     CISTPL_BYTEORDER            = 0x43,
  89.     CISTPL_DATE                    = 0x44,
  90.     CISTPL_BATTERY                = 0x45,
  91.     CISTPL_ORG                    = 0x46,
  92.     CISTPL_VENDOR                = 0xFE,
  93.     CISTPL_END                    = 0xFF
  94. };
  95.  
  96.  
  97. /*————————————————————————————————————————————————————————————————————————
  98.     Tuple Data Block Definitions
  99. ————————————————————————————————————————————————————————————————————————*/
  100.  
  101. /*------------    Device Information Tuple (01H, 17H)    -----------                            */
  102.  
  103.  
  104. struct DeviceIDTuple {
  105.     Byte                             TPLDEV_TYPE_WPS_SPEED;        /* Device Type Code: 7-4, WPS: 3,  Device Speed: 2-0*/
  106.     Byte                             deviceData[253];
  107. };
  108. typedef struct DeviceIDTuple            DeviceIDTuple;
  109.  
  110. enum {
  111.     TPLDEV_TYPE_MASK            = 0xF0,                            /* device type mask for TPLDEV_TYPE_WPS_SPEED*/
  112.     TPLDEV_TYPE_EXTENDED        = 0xE0,                            /* device type value for extended type*/
  113.     TPLDEV_WPS_MASK                = 0x08,                            /* write-protect switch mask for TPLDEV_TYPE_WPS_SPEED*/
  114.     TPLDEV_SPEED_MASK            = 0x07,                            /* device speed mask for TPLDEV_TYPE_WPS_SPEED*/
  115.     TPLDEV_DSPEED_NULL            = 0x00,                            /* speed for null device type*/
  116.     TPLDEV_DSPEED_250NS            = 0x01,                            /* 250ns card access time*/
  117.     TPLDEV_DSPEED_200NS            = 0x02,                            /* 200ns card access time*/
  118.     TPLDEV_DSPEED_150NS            = 0x03,                            /* 150ns card access time*/
  119.     TPLDEV_DSPEED_100NS            = 0x04,                            /* 100ns card access time*/
  120.     TPLDEV_EXTENDED_SPEED        = 0x07,                            /* device speed value for extended speed*/
  121.     TPLDEV_SPEED_EXPONENT        = 0x07,                            /* extended byte exponent mask*/
  122.     TPLDEV_SPEED_MANTISSA        = 0x78,                            /* extended byte mantissa mask*/
  123.     TPLDEV_SPEED_EXTENDED_MASK    = 0x80                            /* bit set if more extended speed data follows*/
  124. };
  125.  
  126.  
  127. /*    device ID types*/
  128.  
  129.  
  130. enum {
  131.     DTYPE_NULL                    = 0,
  132.     DTYPE_ROM                    = 1,
  133.     DTYPE_OTPROM                = 2,
  134.     DTYPE_EPROM                    = 3,
  135.     DTYPE_EEPROM                = 4,
  136.     DTYPE_FLASH                    = 5,
  137.     DTYPE_SRAM                    = 6,
  138.     DTYPE_DRAM                    = 7,
  139.     DTYPE_FUNCSPEC                = 0x0D,
  140.     DTYPE_EXTEND                = 0x0E
  141. };
  142.  
  143.  
  144. /*---------------    Checksum Control Tuple (10H)    ---------------                            */
  145.  
  146.  
  147. struct ChecksumControlTuple {
  148.     short                             TPLCKS_ADDR;                /* offset to region to be checksummed, LSB first*/
  149.     short                             TPLCKS_LEN;                    /* length of region to be checksummed, LSB first*/
  150.     char                             TPLCKS_CS;                    /* checksum of the region*/
  151.     Byte                             reserved;                    /* padding*/
  152. };
  153. typedef struct ChecksumControlTuple        ChecksumControlTuple;
  154. /*----------------    Long Link Multi-Function Tuple (06H)    ------                    */
  155.  
  156.  
  157. struct LongLinkMFCTuple {
  158.     UInt8                             TPLMFC_NUM;                    /* Number of sets of config registers for individual functions*/
  159.  
  160.     UInt8                             TPLMFC_TAS1;                /* CIS target address space for first function (00 = Attr, 01 = Common)*/
  161.     UInt32                             TPLMFC_ADDR1;                /* Target address of first CIS, unsigned long, lsb first*/
  162.  
  163.     UInt8                             TPLMFC_TAS2;                /* CIS target address space for second function (00 = Attr, 01 = Common)*/
  164.     UInt8                             TPLMFC_ADDR2[4];            /* [MISALIGNED!] Target address of second CIS, unsigned long, lsb first*/
  165.  
  166.                                                                 /* the following fields are of undetermined length and should be calculated at runtime*/
  167.                                                                 /* */
  168.                                                                 /* UInt8        TPLMFC_TASn;*/
  169.                                                                 /* UInt32        TPLMFC_ADDRn;*/
  170. };
  171. typedef struct LongLinkMFCTuple            LongLinkMFCTuple;
  172. /*----------------    Long Link Tuple (11H, 12H)    ----------------                            */
  173.  
  174.  
  175. struct LongLinkTuple {
  176.     UInt32                             TPLL_ADDR;                    /* target address, LSB first*/
  177. };
  178. typedef struct LongLinkTuple            LongLinkTuple;
  179. /*-----------------    Link Target Tuple (13H)    ------------------                            */
  180.  
  181.  
  182. struct LinkTargetTuple {
  183.     Byte                             TPLL_TAG[3];                /* tag: should be 'C', 'I', 'S'*/
  184. };
  185. typedef struct LinkTargetTuple            LinkTargetTuple;
  186. /*----------------    Level 1 Version Tuple (15H)    ---------------                            */
  187.  
  188.  
  189. struct Level1VersionTuple {
  190.     Byte                             TPLLV1_MAJOR;                /* major version number (0x04)*/
  191.     Byte                             TPLLV1_MINOR;                /* minor version number (0x01 for release 2.0 and 2.01)*/
  192.     Byte                             TPLLV1_INFO[1];                /* product information string, zero-terminated*/
  193. };
  194. typedef struct Level1VersionTuple        Level1VersionTuple;
  195. /*-------------    JEDEC Identifier Tuple (18H, 19H)    ------------                            */
  196.  
  197.  
  198. struct JEDECDeviceInfo {
  199.     Byte                             manufacturerID;
  200.     Byte                             manufacturerInfo;
  201. };
  202. typedef struct JEDECDeviceInfo            JEDECDeviceInfo;
  203.  
  204. struct JEDECIdentifierTuple {
  205.     JEDECDeviceInfo                 device[1];
  206. };
  207. typedef struct JEDECIdentifierTuple        JEDECIdentifierTuple;
  208. /*---------    Configuration Tuple (1AH)    ----------                            */
  209.  
  210.  
  211. struct ConfigTuple {
  212.     Byte                             TPCC_SZ;                    /* size of fields byte*/
  213.     Byte                             TPCC_LAST;                    /* index number of last config entry*/
  214.     Byte                             TPCC_RADR;                    /* config reg's base addr in reg. space*/
  215.     Byte                             reserved;                    /* padding*/
  216.  
  217.                                                                 /* the following fields are of undetermined length and should be calculated at runtime*/
  218.                                                                 /*UInt32            TPCC_RMSK;*/
  219.                                                                 /*UInt32            TPCC_RSVD;*/
  220.                                                                 /*UInt32            TPCC_SBTPL;*/
  221. };
  222. typedef struct ConfigTuple                ConfigTuple;
  223. /*    TPCC_RADR field definitions*/
  224.  
  225. enum {
  226.     TPCC_RASZ                    = 0x03,                            /* bits 1-0*/
  227.     TPCC_RMSZ                    = 0x3C,                            /* bits 5-2*/
  228.     TPCC_RFSZ                    = 0xC0                            /* bits 7-6*/
  229. };
  230.  
  231.  
  232. /*---------    Device Geometry Tuple (1EH, 1FH)    ----------*/
  233.  
  234.  
  235. struct DeviceGeometry {
  236.     UInt8                             DGTPL_BUS;                    /* system bus width = 2^(n-1), n>0*/
  237.     UInt8                             DGTPL_EBS;                    /* erase block size = 2^(n-1), n>0*/
  238.     UInt8                             DGTPL_RBS;                    /* read block size = 2^(n-1), n>0*/
  239.     UInt8                             DGTPL_WBS;                    /* write block size = 2^(n-1), n>0*/
  240.     UInt8                             DGTPL_PART;                    /* partitioning size = 2^(n-1), n>0*/
  241.     UInt8                             DGTPL_HWIL;                    /* hardware interleave = 2^(n-1), n>0*/
  242. };
  243. typedef struct DeviceGeometry            DeviceGeometry;
  244.  
  245. struct DeviceGeometryTuple {
  246.     DeviceGeometry                     device[42];
  247. };
  248. typedef struct DeviceGeometryTuple        DeviceGeometryTuple;
  249. /*---------    Manufacturer Identification Tuple (20H)    ----------                            */
  250.  
  251.  
  252. struct ManufIDTuple {
  253.     short                             TPLMID_MANF;                /* PCMCIA PC Card manufacturer code*/
  254.     short                             TPLMID_CARD;                /* manufacturer information (part number and/or revision)*/
  255. };
  256. typedef struct ManufIDTuple                ManufIDTuple;
  257. /*-----------    Function Identification Tuple (21H)    ------------                            */
  258.  
  259.  
  260. struct FunctionIDTuple {
  261.     Byte                             TPLFID_FUNCTION;            /* PC card function code*/
  262.     Byte                             TPLFID_SYSINIT;                /* system initialization bit mask*/
  263. };
  264. typedef struct FunctionIDTuple            FunctionIDTuple;
  265. /*    function codes*/
  266.  
  267. enum {
  268.     TPLFID_MultiFunction        = 0,
  269.     TPLFID_Memory                = 1,
  270.     TPLFID_SerialPort            = 2,
  271.     TPLFID_ParallelPort            = 3,
  272.     TPLFID_FixedDisk            = 4,
  273.     TPLFID_VideoAdapter            = 5,
  274.     TPLFID_NetworkLANAdapter    = 6,
  275.     TPLFID_AIMS                    = 7,
  276.     TPLFID_SCSI                    = 8,
  277.     TPLFID_Security                = 9
  278. };
  279.  
  280.  
  281. /*------------    Software Interleave Tuple (23H)    ---------------                            */
  282.  
  283.  
  284. struct SoftwareInterleaveTuple {
  285.     char                             TPLSWIL_INTRLV;                /* software interleave*/
  286. };
  287. typedef struct SoftwareInterleaveTuple    SoftwareInterleaveTuple;
  288. /*-------    Level 2 Version and Information Tuple (40H)    --------                            */
  289.  
  290.  
  291. struct Level2VersionTuple {
  292.     Byte                             TPLLV2_VERS;                /* structure version (0x00)*/
  293.     Byte                             TPLLV2_COMPLY;                /* level of compliance with the standard (0x00)*/
  294.     UInt16                             TPLLV2_DINDEX;                /* byte address of first data byte in card, LSB first*/
  295.     Byte                             TPLLV2_RSV6;                /* reserved, must be zero*/
  296.     Byte                             TPLLV2_RSV7;                /* reserved, must be zero*/
  297.     Byte                             TPLLV2_VSPEC8;                /* vendor specific byte*/
  298.     Byte                             TPLLV2_VSPEC9;                /* vendor specific byte*/
  299.     char                             TPLLV2_NHDR;                /* number of copies of CIS present on this device*/
  300.     char                             TPLLV2_OEM[1];                /* vendor of software that formatted card, zero-terminated*/
  301.     char                             TPLLV2_INFO[1];                /* informational message about the card, zero-terminated*/
  302.     Byte                             reserved;                    /* padding*/
  303. };
  304. typedef struct Level2VersionTuple        Level2VersionTuple;
  305. /*--------------------    Format Tuple (41H)    --------------------                            */
  306.  
  307. /* additional information for disk type:*/
  308.  
  309.  
  310. struct FormatDiskTuple {
  311.     UInt16                             TPLFMT_BKSZ;                /*    block size, or zero if unblocked format*/
  312.     UInt32                             TPLFMT_NBLOCKS;                /*    number of data blocks in this partition*/
  313.     UInt32                             TPLFMT_EDCLOC;                /*    location of error detection code, or zero if interleaved*/
  314. };
  315. typedef struct FormatDiskTuple            FormatDiskTuple;
  316. /* additional information for disk type:*/
  317.  
  318. struct FormatMemTuple {
  319.     Byte                             TPLFMT_FLAGS;                /*    various flags*/
  320.     Byte                             TPLFMT_RESERVED;            /*    reserved, set to zero*/
  321.     UInt32                             TPLFMT_ADDRESS;                /*    physical location at which this memory partion must be mapped*/
  322.     UInt32                             TPLFMT_EDCLOC;                /*    location of error detection code, or zero if interleaved*/
  323. };
  324. typedef struct FormatMemTuple            FormatMemTuple;
  325.  
  326. struct FormatTuple {
  327.     char                             TPLFMT_TYPE;                /* format type code*/
  328.     char                             TPLFMT_EDC;                    /* error detection method and length of error detection code*/
  329.     long                             TPLFMT_OFFSET;                /* offset to first data byte in this partition*/
  330.     long                             TPLFMT_NBYTES;                /* number of data bytes in this partition*/
  331.     union {
  332.         FormatDiskTuple                 TPLFMT_DISK;
  333.         FormatMemTuple                     TPLFMT_MEM;
  334.     }                                 u;
  335. };
  336. typedef struct FormatTuple                FormatTuple;
  337. /*    format types*/
  338.  
  339. enum {
  340.     TPLFMTTYPE_DISK                = 0,
  341.     TPLFMTTYPE_MEM                = 1,
  342.     TPLFMTTYPE_VS                = 0x80
  343. };
  344.  
  345. /*    error detection types*/
  346.  
  347.  
  348. enum {
  349.     TPLFMTEDC_NONE                = 0,
  350.     TPLFMTEDC_CKSUM                = 1,
  351.     TPLFMTEDC_CRC                = 2,
  352.     TPLFMTEDC_PCC                = 3,
  353.     TPLFMTEDC_VS                = 8
  354. };
  355.  
  356. /*    bits in TPLFMT_FLAGS*/
  357.  
  358.  
  359. enum {
  360.     TPLFMTFLAGS_ADDR            = 0,
  361.     TPLFMTFLAGS_AUTO            = 1
  362. };
  363.  
  364.  
  365. /*------------------    Geometry Tuple (42H)    --------------------                            */
  366.  
  367.  
  368. struct GeometryTuple {
  369.     char                             TPLGEO_SPT;                    /* number of sectors per track*/
  370.     char                             TPLGEO_TPC;                    /* number of tracks per cylinder*/
  371.     short                             TPLGEO_NCYL;                /* number of cylinders, total*/
  372. };
  373. typedef struct GeometryTuple            GeometryTuple;
  374. /*-----------------    Byte-Order Tuple (43H)    -------------------                            */
  375.  
  376.  
  377. struct ByteOrderTuple {
  378.     char                             TPLBYTE_ORDER;                /* byte order code*/
  379.     char                             TPLBYTE_MAP;                /* byte mapping code*/
  380. };
  381. typedef struct ByteOrderTuple            ByteOrderTuple;
  382. /*    byte order codes*/
  383.  
  384. enum {
  385.     TYPBYTEORD_LOW                = 0,
  386.     TYPBYTEORD_HIGH                = 1,
  387.     TYPBYTEORD_VS                = 0x80
  388. };
  389.  
  390. /*    byte mapping codes*/
  391.  
  392.  
  393. enum {
  394.     TYPBYTEMAP_LOW                = 0,
  395.     TYPBYTEMAP_HIGH                = 1,
  396.     TYPBYTEMAP_VS                = 0x80
  397. };
  398.  
  399.  
  400. /*----------    Card Initialization Date Tuple (44H)    ------------                            */
  401.  
  402.  
  403. struct CardInitDateTuple {
  404.     UInt16                             TPLDATE_TIME;                /* hours, minutes, seconds*/
  405.     UInt16                             TPLDATE_DAY;                /* year, month, day*/
  406. };
  407. typedef struct CardInitDateTuple        CardInitDateTuple;
  408. /*----------    Battery-Replacement Date Tuple (45H)    ------------                            */
  409.  
  410.  
  411. struct BatteryReplaceDateTuple {
  412.     UInt16                             TPLBATT_RDAY;                /* last replacement date (year, month, day)*/
  413.     UInt16                             TPLBATT_XDAY;                /* battery expiration date (year, month, day)*/
  414. };
  415. typedef struct BatteryReplaceDateTuple    BatteryReplaceDateTuple;
  416.  
  417. /*----------------------    General Tuple    -----------------------                            */
  418.  
  419.  
  420. union TupleBody {
  421.     DeviceIDTuple                     deviceID;
  422.     ChecksumControlTuple             checksum;
  423.     LongLinkTuple                     link;
  424.     LinkTargetTuple                 target;
  425.     Level1VersionTuple                 level1;
  426.     JEDECIdentifierTuple             jedecID;
  427.     ConfigTuple                     config;
  428.     DeviceGeometryTuple             devGeo;
  429.     ManufIDTuple                     manufID;
  430.     FunctionIDTuple                 funcID;
  431.     SoftwareInterleaveTuple         swil;
  432.     Level2VersionTuple                 level2;
  433.     FormatTuple                     format;
  434.     GeometryTuple                     geometry;
  435.     ByteOrderTuple                     order;
  436.     CardInitDateTuple                 initDate;
  437.     BatteryReplaceDateTuple         battDate;
  438.     Byte                             tupleData[254];
  439. };
  440. typedef union TupleBody                    TupleBody;
  441.  
  442. struct Tuple {
  443.     Byte                             TPL_CODE;
  444.     Byte                             TPL_LINK;
  445.     TupleBody                         TPL_BODY;
  446. };
  447. typedef struct Tuple                    Tuple;
  448.  
  449. #if PRAGMA_STRUCT_ALIGN
  450.     #pragma options align=reset
  451. #elif PRAGMA_STRUCT_PACKPUSH
  452.     #pragma pack(pop)
  453. #elif PRAGMA_STRUCT_PACK
  454.     #pragma pack()
  455. #endif
  456.  
  457. #ifdef PRAGMA_IMPORT_OFF
  458. #pragma import off
  459. #elif PRAGMA_IMPORT
  460. #pragma import reset
  461. #endif
  462.  
  463. #ifdef __cplusplus
  464. }
  465. #endif
  466.  
  467. #endif /* __PCCARDTUPLES__ */
  468.  
  469.